package org.ax.controller.process;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ax.data.Result;
import org.ax.pojo.process.Technology;
import org.ax.pojo.process.TechnologyPlan;
import org.ax.pojo.process.TechnologyRequirement;
import org.ax.service.process.TechnologyPlanService;
import org.ax.service.process.TechnologyRequirementService;
import org.ax.service.process.TechnologyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-28-21:01
 */
@RestController
@RequestMapping("/technologyRequirement")
public class TechnologyRequireController {
    @RequestMapping("/find")
    public ModelAndView find(){
        return new ModelAndView("process/technologyRequire");
    }
    @Autowired
    TechnologyRequirementService technologyRequirementService;
    @Autowired
    Result result;
    @GetMapping("/list")
    public Result search(String status,@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int limit){
        Page<TechnologyRequirement> technologyRequirePage = technologyRequirementService.searchTechnologyRequirePage(new Page(page, limit), status);
        result.setData(technologyRequirePage.getRecords());
        result.setCount(technologyRequirePage.getTotal());
        return result;
    }
    @PostMapping("/addTechnologyRequire")
    public Result addProduct(TechnologyRequirement technologyRequirement){
        result.setMsg(technologyRequirementService.addTechnologyRequire(technologyRequirement)?"添加成功":"添加失败");
        return result;

    }
    @PostMapping("/updateTechnologyRequire")
    public Result updateProduct(TechnologyRequirement technologyRequirement){
        result.setMsg(technologyRequirementService.updateTechnologyRequire(technologyRequirement)?"修改成功":"修改失败");
        return result;

    }
    @GetMapping("/patchDel")
    public Result patchDel(String[] ids){
        result.setMsg(technologyRequirementService.deletesTechnologyRequire(ids)?"批量删除成功":"批量删除失败");
        return result;
    }
}
